<template>
  <view class="place-card">
    <view class="place-image-container">
      <image :src="place.image" mode="aspectFill" class="place-image" />
      <view class="price-tag">
        <text class="price-text">{{ place.price }}</text>
      </view>
      <view class="save-button" @click.stop="handleSave">
        <image 
          :src="isSaved ? '/static/images/save-icon-active.svg' : '/static/images/save-icon.svg'" 
          mode="aspectFit" 
          class="save-icon" 
        />
      </view>
    </view>
    <view class="place-info">
      <text class="place-name">{{ place.name }}</text>
      <view class="place-meta">
        <view class="place-location">
          <image src="/static/images/location-icon.svg" mode="aspectFit" class="location-icon" />
          <text class="location-text">{{ place.location }}</text>
        </view>
        <view class="duration-tag">
          <text class="duration-text">{{ place.duration }}</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'PlaceCard',
  props: {
    place: {
      type: Object,
      required: true
    },
    isSaved: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    handleClick() {
      this.$emit('click', this.place)
    },
    handleSave() {
      this.$emit('save', this.place)
    }
  }
}
</script>

<style>
.place-card {
  flex-shrink: 0;
  width: 280px;
  border-radius: 24px;
  overflow: hidden;
  background: #FFFFFF;
  box-shadow: 0px 4px 33px rgba(0, 0, 0, 0.08);
}

.place-image-container {
  position: relative;
  width: 100%;
  height: 180px;
}

.place-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.price-tag {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  padding: 8px 16px;
  border-radius: 20px;
}

.price-text {
  font-size: 13px;
  font-weight: 600;
  color: #000000;
}

.save-button {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.save-icon {
  width: 16px;
  height: 16px;
}

.place-info {
  padding: 16px;
}

.place-name {
  font-size: 15px;
  font-weight: 600;
  color: #000000;
  margin-bottom: 8px;
}

.place-meta {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.place-location {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
}

.location-icon {
  width: 16px;
  height: 16px;
  opacity: 0.5;
}

.location-text {
  font-size: 13px;
  color: #89807A;
}

.duration-tag {
  background: #F0F0F0;
  padding: 6px 12px;
  border-radius: 12px;
  margin-right: 5px;
}

.duration-text {
  font-size: 13px;
  color: #89807A;
}
</style> 